export const createInputList = (list: any[]) => {
  const options: any = [];
  list.forEach((item) => {
    const { type, data, prop, label, attrs = {} } = item;

    let inputObj: any = {};

    if (type === "select") {
      inputObj = {
        // type: "select",
        colConfig: { span: 8 },
        type,
        placeholder: label,
        label,
        prop,
        attrs: {
          filterable: true,
          clearable: true,
          style: {
            width: "100%",
          },
        },
        children: data,
      };
    } else if (type === "input-number") {
      inputObj = {
        colConfig: { span: 8 },
        type,
        label,
        prop,
        attrs: {
          controls: false,
          clearable: true,
          min: 0,
          precision: 0,
          style: {
            width: "100%",
          },
        },
      };
    } else if (type === "date-picker") {
      inputObj = {
        colConfig: { span: 8 },
        type,
        placeholder: label,
        prop,
        label,
        attrs: {
          clearable: true,
          type: "date",
          "value-format": "YYYY-MM-DD", // YYYY-MM-DD HH:mm:ss
          class: "!w-1/1",
          style: {
            width: "100%",
          },
        },
      };
    } else if (type === "tree-select") {
      inputObj = {
        colConfig: { span: 8 },
        type,
        placeholder: label,
        prop,
        label,
        attrs: {
          filterable: true,
          clearable: true,
          data,
          // props: defaultProps,
          "check-strictly": true,
          // "node-key": "id",
        },
      };
    } else {
      inputObj = {
        colConfig: { span: 8 },
        type: "input",
        label,
        prop,
        placeholder: label,
        attrs: {
          style: { width: "100%" },
          clearable: true,
        },
      };
    }

    Object.assign(inputObj, attrs);
    options.push(inputObj);
  });
  return options;
};
